<?php
/**
 * @var $this \yii\web\View
 * @var $model \app\modules\admin\models\AuthItem
 * @var $context \app\modules\admin\components\ItemController
 * Created by PhpStorm.
 * User: jiangjunxian
 * Date: 2016/12/13
 * Time: 16:37
 */

use yii\bootstrap\Html;

$context = $this->context;
$labels = $context->labels();
$this->title = $model->name;
$this->params['breadcrumbs'][] = ['label' => $labels['Items'], 'url'=> ['index']];
$this->params['breadcrumbs'][] = $this->title;

$opts = \yii\helpers\Json::htmlEncode($model->getItems());

$this->registerJs("var _opts = {$opts};");
$this->registerJs($this->render('_script.js'));
$animateIcon = ' <i class="fa fa-spinner fa-pulse fa-fw"></i>';
?>
<div class="row">
	<div class="col-sm-12">
		<div class="box box-success">
			<div class="box-header">
				<h3 class="box-title"><?= $this->title ?></h3>
				<div class="box-tools">
					<?= Html::a('更新', ['update', 'id' => $model->name], ['class'=>'btn btn-primary']) ?>
					<?= Html::a('删除', ['delete', 'id' => $model->name], [
						'class' => 'btn btn-danger',
						'data-confirm' => "确定删除这个{$labels['Item']}吗？",
						'data-method' => 'post',
					]) ?>
					<?= Html::a('新建', ['create'], ['class'=>'btn btn-success']) ?>
				</div>
			</div>
			<div class="box-body">
				<?= \yii\widgets\DetailView::widget([
					'model' => $model,
					'attributes' => [
						'name',
						'description:ntext',
						'ruleName',
						'data:ntext',
					],
					'template' => '<tr><th style="width: 120px;">{label}</th><td>{value}</td></tr>'
				]) ?>
			</div>
		</div>
	</div>
</div>
<div class="row">
	<div class="col-sm-5">
		<div class="box box-primary">
			<div class="box-body">
				<input type="text" class="form-control search" data-target="available" placeholder="查找存在的<?= $labels['Item'] ?>"	>
				<select multiple id="available" size="20" class="form-control list"></select>
			</div>
		</div>
	</div>
	<div class="col-sm-2">
		<?= Html::a('<i class="fa fa-long-arrow-right"></i>' . $animateIcon, ['assign', 'id' => $model->name], [
			'class' => 'btn btn-success btn-block btn-assign',
			'data-target' => 'available',
			'title' => '获取',
			'style' => 'margin-top: 80px; margin-bottom: 20px;'
		]) ?>
		<?= Html::a('<i class="fa fa-long-arrow-left"></i>' . $animateIcon, ['remove', 'id' => $model->name], [
			'class' => 'btn btn-danger btn-block btn-assign',
			'data-target' => 'assigned',
			'title' => '移除',
		]) ?>
	</div>
	<div class="col-sm-5">
		<div class="box box-info">
			<div class="box-body">
				<input type="text" class="form-control search" data-target="assigned" placeholder="查找获取的<?= $labels['Item'] ?>">
				<select multiple id="assigned" size="20" class="form-control list"></select>
			</div>
		</div>
	</div>
</div>
